﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommonLib;

namespace Cinema
{
    public struct FilmUniqueKey
    {
        private string _name;
        private string _director;

        public string Name
        {
            get { return _name; }
            internal set
            {
                CheckName(value);
                _name = value;
            }
        }
        public string Director
        {
            get { return _director; }
            internal set
            {
                CheckDirector(value);
                _director = value;
            }
        }

        public FilmUniqueKey(string name, string director)
        {
            CheckName(name);
            CheckDirector(director);

            _name = name;
            _director = director;
        }

        public override int GetHashCode()
        {
            return Name.GetHashCode() ^ Director.GetHashCode();
        }

        public static void CheckName(string name)
        {
            if (string.IsNullOrEmpty(name))
                throw new ArgumentException("The film name can't be null or empty", "name");
        }
        public static void CheckDirector(string director)
        {
            if (string.IsNullOrEmpty(director))
                throw new ArgumentException("The film director can't be null or empty", "director");
        }
    }
    public interface IFilm : IBusinessEntity<FilmUniqueKey>
    {
        string Name { get; set; }
        string Description { get; set; }
        string Director { get; set; }
        PositiveValue<short> Duration { get; set; }
        string ImagePath { get; set; }
        DateTime? DiscontinueDate { get; set; }
    }
}
